package com.songcha.sakura.mvvm.local.downloaad

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.songcha.library_base.base.BaseFragment
import com.songcha.sakura.databinding.FragmentDownloadBinding
import com.songcha.sakura.ui.adapter.DownloadingAdapter


class LocalDownloadFragment : BaseFragment()  {
    companion object{
        val TAG:String= LocalDownloadFragment::class.java.simpleName
    }
    private var _binding: FragmentDownloadBinding? = null

    // This property is only valid between onCreateView and
    // onDestroyView.
    private val binding get() = _binding!!

    //private var mList:MutableList<DownloadTask> = mutableListOf()

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {

      //  val downloadViewModel =
      //      ViewModelProvider(this).get(DownloadViewModel::class.java)


        _binding = FragmentDownloadBinding.inflate(inflater, container, false)
        val root: View = binding.root


        val cateTitles=arrayListOf("本地视频","正在下载")
        val vp=binding.vpDownload
        vp.adapter=DownloadingAdapter(childFragmentManager,cateTitles)

        binding.ctlDownload.setViewPager(vp)

        return root
    }


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        /*_binding!!.btnDownload.setOnClickListener {
            startDownload("https://hot.qqaku.com/20230225/wfURq4s2/index.m3u8")
        }*/

    }

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }




}